//
// Created by YE on 2024/2/16.
//

#ifndef MATINTERPRETER_YCH_STACK_H
#define MATINTERPRETER_YCH_STACK_H

#include "ych_exception.h"
#include "ych_object.h"

#define SYN_STACK_SIZE 64
#define SEM_STACK_SIZE 16
typedef unsigned int T;
typedef enum MType {
    MT_NONE,
    MT_VAR, MT_T, MT_MAT_V, MT_OBJ_P,
    MT_INT_CONST, MT_FLOAT_CONST, MT_BOOL_CONST, MT_STRING_CONST,
    MT_ASSIGN,
    MT_IP, MT_WP
} MType;
typedef struct MInfo {
    MType type;
    union MValue {
        Uint p;    //内存地址
        Int i;
        Float f;
        Bool b;
    } value;
} MInfo;
typedef struct SYNStack {
    int top;
    Uint capacity;
    T *array;
} SYNStack;
typedef struct SEMStack {
    int top;
    Uint capacity;
    MInfo *array;
} SEMStack;

void initSYNStack(SYNStack *stack);

void pushSYNStack(SYNStack *stack, T item);

int isEmptySYNStack(SYNStack *stack);

T topSYNStack(SYNStack *stack);

T popSYNStack(SYNStack *stack);

void freeSYNStack(SYNStack *stack);

void initSEMStack(SEMStack *stack);

void pushSEMStack(SEMStack *stack, MInfo item);

int isEmptySEMStack(SEMStack *stack);

MInfo topSEMStack(SEMStack *stack);

MInfo popSEMStack(SEMStack *stack);

void freeSEMStack(SEMStack *stack);

#endif //MATINTERPRETER_YCH_STACK_H
